﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Web.Mvc;
using Project.Module;
using Project.Module.Common;
using Project.Module.DAO;
using Project.Module.DAO.BL;
using Project.Module.DAO.CMSBL;
using Project.Module.Model;
using Project.Module.Model.CMS;
using Project.Engine.Control;
using Project.Engine.Utilities;

namespace Project.Module.View.CMS
{
    public class CMSSearchNewsView : BasePageRazor
    {
        public string keywordTitle = String.Empty;
        public string keywordContent = String.Empty;
        public string choice = "0";
        public List<NewsModel> listNews { get; set; }
        private NewsBL newBl = new NewsBL();

        protected override void InitializePage()
        {
            base.InitializePage();

            if (Request["keywordTitle"] != null || Request["keywordContent"] != null)
            {
                keywordTitle = Request["keywordTitle"] != "  " ? SecurityUtil.RemoveSqlInjection(Request["keywordTitle"].ToString()) : String.Empty;
                keywordContent = Request["keywordContent"] != "  " ? SecurityUtil.RemoveSqlInjection(Request["keywordContent"].ToString()) : String.Empty;

                if (keywordTitle == String.Empty && keywordContent == String.Empty)
                {
                    listNews = null;

                }
                else
                {
                    listNews = newBl.Search(keywordTitle, keywordContent);
                }
            }
        }
    }
}
